import React from "react";
import "../../../../static/css/pc/bd_it.css";

export default class BdIt extends React.Component{

	constructor(){
		super();
		this.state = {
			it:[]
		}
	}

	// 1.直接传递数据源    2.传递参数，自己进行网络请求

	componentDidMount(){
		var result = fetch(this.props.url,{
			method:"get"
		})
		.then(res => {
			return res.json();
		})
		.then(json => {
			this.setState({
				it:json
			})
		})
	}

	render(){

		var { it } = this.state;

		return(
			<div className="it">
				<ul>
				{
					it.map((item,index) => {
						return (
							<li key={index} style={this.props.itStyle}>
								<a href={item.url}>
									<img src={item.thumbnail_pic_s} alt=""/>
									<p>{item.title}</p>
								</a>
							</li>
						)
					})	
				}
				</ul>
			</div>
		)
	}
}